2feat: Set exported SVG tag ID to its source layer name#3530
Open
theaniketgiri wants to merge 1 commit intoGraphiteEditor:masterfrom
Open
2feat: Set exported SVG tag ID to its source layer name#3530theaniketgiri wants to merge 1 commit intoGraphiteEditor:masterfrom
theaniketgiri wants to merge 1 commit intoGraphiteEditor:masterfrom
Conversation
Implements GraphiteEditor#2879: When exporting artwork as SVG, group elements (<g> tags) now include an 'id' attribute set to the layer's display name. Changes: - Add node_names HashMap to RenderParams and RenderConfig to pass layer names from editor to rendering system - Add sanitize_svg_id() to convert layer names to valid SVG IDs: - Replaces spaces and colons with underscores - Strips invalid XML Name characters - Ensures ID starts with letter or underscore - Add make_unique_svg_id() to handle duplicate names with _2, _3 suffixes - Modify Table<Graphic>::render_svg() to add id attribute during export - Collect layer names recursively including nested layers/groups - Skip default 'Untitled Layer' and 'Untitled Node' names - Add comprehensive unit tests for ID sanitization and deduplication Example: A layer named 'my:square' exports as <g id='my_square'> Duplicate names get suffixes: 'Layer', 'Layer_2', 'Layer_3' Closes GraphiteEditor#2879
124235a to
a42cad8
Compare
Ayush2k02
suggested changes
Feb 11, 2026
| .filter_map(|(node_id, _, network_path)| { | ||
| let name = document.network_interface.display_name(node_id, &network_path); | ||
| // Skip default "Untitled Layer" and "Untitled Node" names | ||
| if name.starts_with("Untitled") { |
Contributor
There was a problem hiding this comment.
This would skip any user-named layer starting with "Untitled"
d6228da to
e58c1de
Compare
9b97ab7 to
2e842cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #2879: When exporting artwork as SVG, group elements ( tags) now include an 'id' attribute set to the layer's display name.
Changes:
Example: A layer named 'my:square' exports as
Duplicate names get suffixes: 'Layer', 'Layer_2', 'Layer_3'
Closes #2879